Evaluator Contract Spec (1)
Overview
The Evaluator contract functions as a reward tracker and payout generator for multiple payees. It calculates the total shares allocated to each payee during an evaluation round and then delegates the actual payout creation to a factory contract.
Requirements
- Asynchrony: The evaluation process must not be blocked waiting for measurements to come in or for nodes to be available.
- The evaluation contract must be able to access the evaluation function
- In the Commitment & epoch summary on chain model, the evaluation contract must be able to challenge nodes to provide proofs of job inclusion.
- To reduce on chain costs, the evaluation must happen off-chain with proof of correct computation submitted on chain
Data model
Share
TODO
Payout
TODO
Payee
TODO
Variables
_totalShares (private, uint256)
Represents the total number of shares allocated during the current evaluation round.
_payoutIndex (private, uint256)
The index of the current evaluation round.
_shares (private, mapping)
A nested mapping that links each evaluation round to a mapping of payee addresses and their share amounts.
_payees (private, address[])
A list of the addresses of all payees.
Functions
Constructor: constructor(address admin)
This function sets the contract's administrator.
Fallback function: receive() external payable virtual
This function is called whenever the contract receives FIL. It emits a PaymentReceived event with the sender's address and the amount of FIL received.
payout() external onlyRole(DEFAULT_ADMIN_ROLE) returns (address instance)
This function is used by the admin to initiate a payout. It calculates the share allocation for each payee and uses the total shares to spin out a PaymentSplitter contract, which then generates a new payout. The function resets the payees and total shares for the next evaluation round and increments the payout index.
releasable(address account) external view returns (uint256 totalValue)
This function returns the total amount of FIL that an account can claim from the PayoutFactory contract.
claim(address account) external
This function allows an account to claim all their available funds from the PayoutFactory contract.
rewardPayee(address account, uint256 shares_) external onlyRole(DEFAULT_ADMIN_ROLE)
This function is used by the admin to reward a payee by allocating them a certain number of shares. If the payee is new, their address is added to the _payees list. The function updates the total shares and the payee's share allocation and emits a RewardedPayee event.
The utility of this function lies in one-off payments, which for example might be issued after settling a dispute.
Getters
payees()
Return the list of payees
totalShares()
Return the total shares for the current evaluation round
shares(address account)
Return the number of shares allocated to a specific account for the current evaluation round
Events
Payout(address newSplitter)
This event is emitted when a new payout contract is created.
PaymentReceived(address from, uint256 amount)
This event is emitted when the contract receives FIL.
RewardedPayee(address account, uint256 shares)
This event is emitted when a payee is allocated shares.